Ext.BLANK_IMAGE_URL="extjs/resources/images/s.gif";
//页面加载事件
Ext.onReady(function(){
	if(Ext.isIE) {
		if(Ext.isIE6) {
			//弹出对话框提示用户不支持IE6
			Ext.Msg.alert("提示","您的浏览器版本较低，请升级后重试！");
			return;
		}
	} 
	var loginform = new Ext.form.Panel({
		width : 285,
		height : 170,
		frame : true,
		resizable : false,
		url: "manager/login.action",
		method:"post",
		bodyStyle:"padding-top:40px;",
		items : [{
			id: "username",
			xtype:"textfield",
			name : "user.username",
			fieldLabel : "帐号",
			labelWidth:40,
			allowBlank : false
		},{
			xtype:"textfield",
			fieldLabel : "密码",
			name : "user.password",
			allowBlank : false,
			labelWidth:40,
			inputType : "password"
		}],
		buttons : [{
			id : "login",
			text: "登录",
			formBind: true,
			handler: login
		},{
			id : "reset",
			text : "重置",
			handler : function(){
				loginform.form.reset();
			}
		}]
	});
	function login() {
				var form = loginform.form;
				if(form.isValid()) {
					form.submit({
			            waitMsg: '验证中，请稍等...',
						success: function(form, action){
//							Ext.Msg.alert("提示",action.result.msg);//登录成功提示
							if(Ext.isIE) {
								window.location.href="index.jsp";
							}else if(Ext.isChrome || Ext.isFF3_6) {
								window.location.href="manager/index.jsp";
							} else {
								window.location.href="manager/index.jsp";
							}
						},
						failure: function(form, action) {
							if(action != null && action.result != null && action.result.msg != null) {
								Ext.Msg.alert("提示",action.result.msg);
							} else {
								Ext.Msg.alert("提示","服务器故障，请稍后重试！");
							}
						}
					});
				}
			}
	//添加键盘响应事件
	Ext.get("body").addListener( "keypress", function(evt){
		if(evt.getKey() == Ext.EventObject.ENTER) {
			login();
		}
	});
	//创建登录窗口
	var loginWin = new Ext.window.Window({
		title: "用户登录",
		height: 200,
		width: 300,
//		frame: true,
		float: true,
		shadow: true,
		layout: 'fit',
		closable: false,
		shadow: true,
		draggable: false,
		modal: true,	//是否模式对话框
		resizable: false,
		bodyStyle:"text-align:center",
//		buttonAlign: "center",
//		focusOnToFront : true,
		items: loginform
	});
	loginWin.show();
//	Ext.getBody("body").setStyle("background","#efefef");
	Ext.getCmp("username").focus(true, 100);
	Ext.getCmp("login").onFocus();
});
